package Lab12Package;

//Java分支语句

public class Lab12_07 {
	public static void main(String[] args) {
		// if语句
		System.out.println("1) if语句");
		int x = 10;
		if (x < 20) {
			System.out.println("这是 if 语句");
		}

		// if-else语句
		System.out.println("\n2) if-else语句");
		int x1 = 30;
		if (x1 < 20) {
			System.out.print("这是 if 语句\n");
		} else {
			System.out.print("这是 else 语句\n");
		}

		// if...else if...else 语句
		System.out.println("\n3) if-else if-else语句");
		int x11 = 30;
		if (x11 == 10) {
			System.out.println("Value of X11 is 10");
		} else if (x11 == 20) {
			System.out.println("Value of X11 is 20");
		} else if (x11 == 30) {
			System.out.println("Value of X11 is 30");
		} else {
			System.out.println("这是 else 语句");
		}

		// 嵌套的 if…else 语句
		System.out.println("\n4) 嵌套的if…else语句");
		int a = 30;
		int y = 10;

		if (a == 30) {
			if (y == 10) {
				System.out.println("a = 30 and Y = 10");
			}
		}

		// switch case 语句
		System.out.println("\n5) switch case 语句");
		char grade = 'C';
		switch (grade) {
			case 'A' :
				System.out.println("优秀");
				break;
			case 'B' :
				System.out.println("良好");
				break;
			case 'C' :
				System.out.println("中");
				break;
			case 'D' :
				System.out.println("及格");
				break;
			case 'F' :
				System.out.println("你需要再努力努力");
				break;
			default :
				System.out.println("未知等级");
		}
		System.out.println("你的等级是 " + grade);
	}
}
